﻿namespace Leetcode.M0105;
public class Solution
{
    public bool OneEditAway(string first, string second)
    {
        if (Math.Abs(first.Length - second.Length) >= 2)
        {
            return false;
        }

        int count = 0;
        for (int i = 0, j = 0; i < first.Length && j < second.Length && count < 2; i++, j++)
        {
            if (first[i] == second[j])
            {
                continue;
            }
            else
            {
                count++;
                if (first.Length < second.Length)
                {
                    i--;
                }
                else if (first.Length > second.Length)
                {
                    j--;
                }
            }
        }

        return count < 2;
    }
}